package vn.com.hoasua.database;

import com.hoasua.database.R;

import vn.com.hoasua.database.smng.LinkMng;
import vn.com.hoasua.database.smng.LogDbMng;
import android.annotation.SuppressLint;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

@SuppressLint("SdCardPath")
public class SDataBaseHelper extends adbSqlHelper {

	public SDataBaseHelper(Context context) {
		super(context, "/data/data/"+context.getPackageName(), context.getString(R.string.database_name), Integer.valueOf(context.getString(R.string.database_version)));
		if(context.getString(R.string.debug).equals("true")){
			Log.e("db path", "/data/data/"+context.getPackageName());
			Log.e("db_name",context.getString(R.string.database_name));
			Log.e("db_version", Integer.valueOf(context.getString(R.string.database_version))+"");
		}
	}

	@Override
	public void createAdb(SQLiteDatabase db) {
		db.execSQL(getSql(LinkMng.TABLE,LinkMng.COLUMNS));
		db.execSQL(getSql(LogDbMng.TABLE,LogDbMng.COLUMNS));
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + LinkMng.TABLE+" ;");
		db.execSQL("DROP TABLE IF EXISTS " + LogDbMng.TABLE+" ;");
		createAdb(db);
	}

}
